<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <style>
    </style>
</head>
<body>

</body>
<script>
    var start = 0;
    var end = 20;
    //打点计时器
    count(start,end)
    function count(start,end) {
        if(start<end){
            console.log(start)
            start++;
            st = setTimeout(function () {
                count(start,end)
            },1000)
        }
        return{
            cancel:function () {
                clearTimeout(st)
            }
        }
    }




</script>
</html>